package com.flmz.judge.rabbitmq;

import com.flmz.api.domain.dto.JudgeSubmitDTO;
import com.flmz.common.core.constants.RabbitMQConstants;
import com.flmz.judge.service.IJudgeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class JudgeConsumer {

	@Autowired
	private IJudgeService judgeService;

	// 监听mq。一有消息就消费
	@RabbitListener(queues = RabbitMQConstants.OJ_WORK_QUEUE)
	public void consume(JudgeSubmitDTO judgeSubmitDTO) {
		log.info("收到消息为: {}", judgeSubmitDTO);
		judgeService.doJudgeJavaCode(judgeSubmitDTO);
	}
}